﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Model;
using Control;

namespace BioBooking
{
    public partial class CinemaHallPanels : UserControl
    {
        private BookingController bookingCtr;
        private GUIBooking guiBooking;
        private List<Label> seatsLabels;

        public CinemaHallPanels(GUIBooking guiBooking)
        {
            this.guiBooking = guiBooking;
            bookingCtr = new BookingController();
            InitializeComponent();
            seatsLabels = new List<Label>();
            AddSeatsLabelsToContainer();
        }

        public void AddSeatsLabelsToContainer()
        {
            foreach (Label label in panel5.Controls)
            {
                seatsLabels.Add(label);
            }
            foreach (Label label in panel1.Controls)
            {
                seatsLabels.Add(label);
            }
            //foreach (Label label in seatsLabels)
            //{
            //    Console.WriteLine(label.Name);
            //}
            
        }

        public Panel PanelA
        {
            get { return panel5; }
        }

        public Panel PanelB
        {
            get { return panel1; }
        }


        private void SeatClick(Label label)
        {
            if (guiBooking.DateListBox.SelectedIndex == -1 || guiBooking.ShowListBox.SelectedIndex == -1)
            {
                // FEJL vælg dato og show
                MessageBox.Show("Du skal vælge data og forestilling først", "Vælg dato og forestilling");
            }
            else
            {
                if (label.BackColor != Color.Red)
                {
                    if (label.BackColor == Color.PaleGreen)
                    {
                        label.BackColor = Color.Transparent;
                        guiBooking.SeatIdsChoicen.Remove(label);
                    }
                    else
                    {
                        label.BackColor = Color.PaleGreen;
                        guiBooking.SeatIdsChoicen.Add(label);
                    }

                    if (label.Name.Contains("a"))
                    {
                        guiBooking.UpdateLabels("a", "A");
                    }
                    else
                    {
                        guiBooking.UpdateLabels("b", "B");
                    }
                }
            }
        }

        public void SetSeatsTaken(Show showObj, bool retriveAssociation)
        {
            foreach (Seat seatObj in bookingCtr.GetSeatsTaken(showObj, retriveAssociation))
            {
                string seatId = seatObj.SeatId.ToLower();
                seatId = seatId.Replace("-", "");

                Label label = FindSeatsLabel(seatId);

                label.BackColor = Color.Red;
            }
        }

        public Label FindSeatsLabel(string seatId)
        {
            int index = 0;
            bool found = false;
            while(index < seatsLabels.Count && !found)
            {
                if (seatsLabels[index].Name.Equals(seatId))
                {
                    found = true;
                }
                else
                {
                    index++;
                }
            }
            if (found)
            {
                return seatsLabels[index];
            }
            else
            {
                return null;
            }
        }

        private void a1_Click(object sender, EventArgs e)
        {
            SeatClick(a1);
        }

        private void a2_Click(object sender, EventArgs e)
        {
            SeatClick(a2);
        }

        private void a3_Click(object sender, EventArgs e)
        {
            SeatClick(a3);
        }

        private void a4_Click(object sender, EventArgs e)
        {
            SeatClick(a4);
        }

        private void a5_Click(object sender, EventArgs e)
        {
            SeatClick(a5);
        }

        private void a6_Click(object sender, EventArgs e)
        {
            SeatClick(a6);
        }

        private void a7_Click(object sender, EventArgs e)
        {
            SeatClick(a7);
        }

        private void a8_Click(object sender, EventArgs e)
        {
            SeatClick(a8);
        }

        private void a9_Click(object sender, EventArgs e)
        {
            SeatClick(a9);
        }

        private void a10_Click(object sender, EventArgs e)
        {
            SeatClick(a10);
        }

        private void a11_Click(object sender, EventArgs e)
        {
            SeatClick(a11);
        }

        private void a12_Click(object sender, EventArgs e)
        {
            SeatClick(a12);
        }

        private void a13_Click(object sender, EventArgs e)
        {
            SeatClick(a13);
        }

        private void a14_Click(object sender, EventArgs e)
        {
            SeatClick(a14);
        }

        private void a15_Click(object sender, EventArgs e)
        {
            SeatClick(a15);
        }

        private void a16_Click(object sender, EventArgs e)
        {
            SeatClick(a16);
        }

        private void a17_Click(object sender, EventArgs e)
        {
            SeatClick(a17);
        }

        private void a18_Click(object sender, EventArgs e)
        {
            SeatClick(a18);
        }

        private void a19_Click(object sender, EventArgs e)
        {
            SeatClick(a19);
        }

        private void a20_Click(object sender, EventArgs e)
        {
            SeatClick(a20);
        }

        private void a21_Click(object sender, EventArgs e)
        {
            SeatClick(a21);
        }

        private void a22_Click(object sender, EventArgs e)
        {
            SeatClick(a22);
        }

        private void a23_Click(object sender, EventArgs e)
        {
            SeatClick(a23);
        }

        private void a24_Click(object sender, EventArgs e)
        {
            SeatClick(a24);
        }

        private void a25_Click(object sender, EventArgs e)
        {
            SeatClick(a25);
        }

        private void a26_Click(object sender, EventArgs e)
        {
            SeatClick(a26);
        }

        private void a27_Click(object sender, EventArgs e)
        {
            SeatClick(a27);
        }

        private void a28_Click(object sender, EventArgs e)
        {
            SeatClick(a28);
        }

        private void a29_Click(object sender, EventArgs e)
        {
            SeatClick(a29);
        }

        private void a30_Click(object sender, EventArgs e)
        {
            SeatClick(a30);
        }

        private void a31_Click(object sender, EventArgs e)
        {
            SeatClick(a31);
        }

        private void a32_Click(object sender, EventArgs e)
        {
            SeatClick(a32);
        }

        private void a33_Click(object sender, EventArgs e)
        {
            SeatClick(a33);
        }

        private void a34_Click(object sender, EventArgs e)
        {
            SeatClick(a34);
        }

        private void a35_Click(object sender, EventArgs e)
        {
            SeatClick(a35);
        }

        private void a36_Click(object sender, EventArgs e)
        {
            SeatClick(a36);
        }

        private void a37_Click(object sender, EventArgs e)
        {
            SeatClick(a37);
        }

        private void a38_Click(object sender, EventArgs e)
        {
            SeatClick(a38);
        }

        private void a39_Click(object sender, EventArgs e)
        {
            SeatClick(a39);
        }

        private void a40_Click(object sender, EventArgs e)
        {
            SeatClick(a40);
        }

        private void a41_Click(object sender, EventArgs e)
        {
            SeatClick(a41);
        }

        private void a42_Click(object sender, EventArgs e)
        {
            SeatClick(a42);
        }

        private void a43_Click(object sender, EventArgs e)
        {
            SeatClick(a43);
        }

        private void a44_Click(object sender, EventArgs e)
        {
            SeatClick(a44);
        }

        private void a45_Click(object sender, EventArgs e)
        {
            SeatClick(a45);
        }

        private void a46_Click(object sender, EventArgs e)
        {
            SeatClick(a46);
        }

        private void a47_Click(object sender, EventArgs e)
        {
            SeatClick(a47);
        }

        private void a48_Click(object sender, EventArgs e)
        {
            SeatClick(a48);
        }

        private void a49_Click(object sender, EventArgs e)
        {
            SeatClick(a49);
        }

        private void a50_Click(object sender, EventArgs e)
        {
            SeatClick(a50);
        }

        private void a51_Click(object sender, EventArgs e)
        {
            SeatClick(a51);
        }

        private void a52_Click(object sender, EventArgs e)
        {
            SeatClick(a52);
        }

        private void a53_Click(object sender, EventArgs e)
        {
            SeatClick(a53);
        }

        private void a54_Click(object sender, EventArgs e)
        {
            SeatClick(a54);
        }

        private void a55_Click(object sender, EventArgs e)
        {
            SeatClick(a55);
        }

        private void a56_Click(object sender, EventArgs e)
        {
            SeatClick(a56);
        }

        private void a57_Click(object sender, EventArgs e)
        {
            SeatClick(a57);
        }

        private void a58_Click(object sender, EventArgs e)
        {
            SeatClick(a58);
        }

        private void a59_Click(object sender, EventArgs e)
        {
            SeatClick(a59);
        }

        private void a60_Click(object sender, EventArgs e)
        {
            SeatClick(a60);
        }

        private void a61_Click(object sender, EventArgs e)
        {
            SeatClick(a61);
        }

        private void a62_Click(object sender, EventArgs e)
        {
            SeatClick(a62);
        }

        private void a63_Click(object sender, EventArgs e)
        {
            SeatClick(a63);
        }

        private void a64_Click(object sender, EventArgs e)
        {
            SeatClick(a64);
        }

        private void a65_Click(object sender, EventArgs e)
        {
            SeatClick(a65);
        }

        private void a66_Click(object sender, EventArgs e)
        {
            SeatClick(a66);
        }

        private void a67_Click(object sender, EventArgs e)
        {
            SeatClick(a67);
        }

        private void a68_Click(object sender, EventArgs e)
        {
            SeatClick(a68);
        }

        private void a69_Click(object sender, EventArgs e)
        {
            SeatClick(a69);
        }

        private void a70_Click(object sender, EventArgs e)
        {
            SeatClick(a70);
        }

        private void a71_Click(object sender, EventArgs e)
        {
            SeatClick(a71);
        }

        private void a72_Click(object sender, EventArgs e)
        {
            SeatClick(a72);
        }

        private void a73_Click(object sender, EventArgs e)
        {
            SeatClick(a73);
        }

        private void a74_Click(object sender, EventArgs e)
        {
            SeatClick(a74);
        }

        private void a75_Click(object sender, EventArgs e)
        {
            SeatClick(a75);
        }

        private void a76_Click(object sender, EventArgs e)
        {
            SeatClick(a76);
        }

        private void a77_Click(object sender, EventArgs e)
        {
            SeatClick(a77);
        }

        private void a78_Click(object sender, EventArgs e)
        {
            SeatClick(a78);
        }

        private void a79_Click(object sender, EventArgs e)
        {
            SeatClick(a79);
        }

        private void a80_Click(object sender, EventArgs e)
        {
            SeatClick(a80);
        }

        private void b72_Click(object sender, EventArgs e)
        {
            SeatClick(b72);
        }

        private void b71_Click(object sender, EventArgs e)
        {
            SeatClick(b71);
        }

        private void b62_Click(object sender, EventArgs e)
        {
            SeatClick(b62);
        }

        private void b70_Click(object sender, EventArgs e)
        {
            SeatClick(b70);
        }

        private void b61_Click(object sender, EventArgs e)
        {
            SeatClick(b61);
        }

        private void b69_Click(object sender, EventArgs e)
        {
            SeatClick(b69);
        }

        private void b63_Click(object sender, EventArgs e)
        {
            SeatClick(b63);
        }

        private void b68_Click(object sender, EventArgs e)
        {
            SeatClick(b68);
        }

        private void b64_Click(object sender, EventArgs e)
        {
            SeatClick(b64);
        }

        private void b67_Click(object sender, EventArgs e)
        {
            SeatClick(b67);
        }

        private void b65_Click(object sender, EventArgs e)
        {
            SeatClick(b65);
        }

        private void b66_Click(object sender, EventArgs e)
        {
            SeatClick(b66);
        }

        private void b48_Click(object sender, EventArgs e)
        {
            SeatClick(b48);
        }

        private void b47_Click(object sender, EventArgs e)
        {
            SeatClick(b47);
        }

        private void b60_Click(object sender, EventArgs e)
        {
            SeatClick(b60);
        }

        private void b46_Click(object sender, EventArgs e)
        {
            SeatClick(b46);
        }

        private void b45_Click(object sender, EventArgs e)
        {
            SeatClick(b45);
        }

        private void b59_Click(object sender, EventArgs e)
        {
            SeatClick(b59);
        }

        private void b44_Click(object sender, EventArgs e)
        {
            SeatClick(b44);
        }

        private void b50_Click(object sender, EventArgs e)
        {
            SeatClick(b50);
        }

        private void b43_Click(object sender, EventArgs e)
        {
            SeatClick(b43);
        }

        private void b58_Click(object sender, EventArgs e)
        {
            SeatClick(b58);
        }

        private void b49_Click(object sender, EventArgs e)
        {
            SeatClick(b49);
        }

        private void b57_Click(object sender, EventArgs e)
        {
            SeatClick(b57);
        }

        private void b42_Click(object sender, EventArgs e)
        {
            SeatClick(b42);
        }

        private void b51_Click(object sender, EventArgs e)
        {
            SeatClick(b51);
        }

        private void b41_Click(object sender, EventArgs e)
        {
            SeatClick(b41);
        }

        private void b56_Click(object sender, EventArgs e)
        {
            SeatClick(b56);
        }

        private void b40_Click(object sender, EventArgs e)
        {
            SeatClick(b40);
        }

        private void b52_Click(object sender, EventArgs e)
        {
            SeatClick(b52);
        }

        private void b39_Click(object sender, EventArgs e)
        {
            SeatClick(b39);
        }

        private void b55_Click(object sender, EventArgs e)
        {
            SeatClick(b55);
        }

        private void b38_Click(object sender, EventArgs e)
        {
            SeatClick(b38);
        }

        private void b53_Click(object sender, EventArgs e)
        {
            SeatClick(b53);
        }

        private void b37_Click(object sender, EventArgs e)
        {
            SeatClick(b37);
        }

        private void b54_Click(object sender, EventArgs e)
        {
            SeatClick(b54);
        }

        private void b36_Click(object sender, EventArgs e)
        {
            SeatClick(b36);
        }

        private void b35_Click(object sender, EventArgs e)
        {
            SeatClick(b35);
        }

        private void b34_Click(object sender, EventArgs e)
        {
            SeatClick(b34);
        }

        private void b33_Click(object sender, EventArgs e)
        {
            SeatClick(b33);
        }

        private void b32_Click(object sender, EventArgs e)
        {
            SeatClick(b32);
        }

        private void b31_Click(object sender, EventArgs e)
        {
            SeatClick(b31);
        }

        private void b30_Click(object sender, EventArgs e)
        {
            SeatClick(b30);
        }

        private void b29_Click(object sender, EventArgs e)
        {
            SeatClick(b29);
        }

        private void b28_Click(object sender, EventArgs e)
        {
            SeatClick(b28);
        }

        private void b27_Click(object sender, EventArgs e)
        {
            SeatClick(b27);
        }

        private void b26_Click(object sender, EventArgs e)
        {
            SeatClick(b26);
        }

        private void b25_Click(object sender, EventArgs e)
        {
            SeatClick(b25);
        }

        private void b24_Click(object sender, EventArgs e)
        {
            SeatClick(b24);
        }

        private void b23_Click(object sender, EventArgs e)
        {
            SeatClick(b23);
        }

        private void b22_Click(object sender, EventArgs e)
        {
            SeatClick(b22);
        }

        private void b21_Click(object sender, EventArgs e)
        {
            SeatClick(b21);
        }

        private void b20_Click(object sender, EventArgs e)
        {
            SeatClick(b20);
        }

        private void b19_Click(object sender, EventArgs e)
        {
            SeatClick(b19);
        }

        private void b18_Click(object sender, EventArgs e)
        {
            SeatClick(b18);
        }

        private void b17_Click(object sender, EventArgs e)
        {
            SeatClick(b17);
        }

        private void b16_Click(object sender, EventArgs e)
        {
            SeatClick(b16);
        }

        private void b15_Click(object sender, EventArgs e)
        {
            SeatClick(b15);
        }

        private void b14_Click(object sender, EventArgs e)
        {
            SeatClick(b14);
        }

        private void b13_Click(object sender, EventArgs e)
        {
            SeatClick(b13);
        }

        private void b12_Click(object sender, EventArgs e)
        {
            SeatClick(b12);
        }

        private void b11_Click(object sender, EventArgs e)
        {
            SeatClick(b11);
        }

        private void b10_Click(object sender, EventArgs e)
        {
            SeatClick(b10);
        }

        private void b9_Click(object sender, EventArgs e)
        {
            SeatClick(b9);
        }

        private void b8_Click(object sender, EventArgs e)
        {
            SeatClick(b8);
        }

        private void b7_Click(object sender, EventArgs e)
        {
            SeatClick(b7);
        }

        private void b6_Click(object sender, EventArgs e)
        {
            SeatClick(b6);
        }

        private void b5_Click(object sender, EventArgs e)
        {
            SeatClick(b5);
        }

        private void b4_Click(object sender, EventArgs e)
        {
            SeatClick(b4);
        }

        private void b3_Click(object sender, EventArgs e)
        {
            SeatClick(b3);
        }

        private void b2_Click(object sender, EventArgs e)
        {
            SeatClick(b2);
        }

        private void b1_Click(object sender, EventArgs e)
        {
            SeatClick(b1);
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void CinemaHallPanels_Load(object sender, EventArgs e)
        {

        }
    }
}
